package io.geekidea.boot.test.controller;

import io.geekidea.boot.framework.page.Paging;
import io.geekidea.boot.framework.response.ApiResult;
import io.geekidea.boot.test.query.AppInvoiceRecordQuery;
import io.geekidea.boot.test.service.InvoiceRecordService;
import io.geekidea.boot.test.vo.AppInvoiceRecordVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * App发票申请记录 控制器
 *
 * @author geekidea
 * @since 2025-03-26
 */
@Slf4j
@RestController
@Tag(name = "App发票申请记录")
@RequestMapping("/app/invoiceRecord")
public class AppInvoiceRecordController {

    @Autowired
    private InvoiceRecordService invoiceRecordService;

    /**
     * 获取App发票申请记录详情
     *
     * @param id
     * @return
     * @throws Exception
     */
    @Operation(summary = "获取App发票申请记录详情")
    @PostMapping("/getAppInvoiceRecord/{id}")
    public ApiResult<AppInvoiceRecordVo> getAppInvoiceRecord(@PathVariable Long id) {
        log.info("获取App发票申请记录详情：{}", id);
        AppInvoiceRecordVo appInvoiceRecordVo = invoiceRecordService.getAppInvoiceRecordById(id);
        return ApiResult.success(appInvoiceRecordVo);
    }

    /**
     * 获取App发票申请记录分页列表
     *
     * query
     * @return
     * @throws Exception
     */
    @Operation(summary = "获取App发票申请记录分页列表")
    @PostMapping("/getAppInvoiceRecordPage")
    public ApiResult<AppInvoiceRecordVo> getAppInvoiceRecordPage(@Valid @RequestBody AppInvoiceRecordQuery query) {
        log.info("获取App发票申请记录分页列表：{}", query);
        Paging<AppInvoiceRecordVo> paging = invoiceRecordService.getAppInvoiceRecordPage(query);
        return ApiResult.success(paging);
    }

}
